package x_yeyue.obj;

import x_yeyue.GameWin;
import x_yeyue.utils.GameUtils;

import java.awt.*;

public class LittleBoss1Bullet extends GameObj{
    public LittleBoss1Bullet(int x, int y) {
        super(x, y);
    }

    public LittleBoss1Bullet(Image img, int width, int height, int x, int y, double speed, GameWin frame) {
        super(img, width, height, x, y, speed, frame);
    }

    public LittleBoss1Bullet() {
    }

    @Override
    public Rectangle getRec() {
        return super.getRec();
    }

    @Override
    public void paintSelf(Graphics g) {
        super.paintSelf(g);
        // 实现追踪效果
        this.y += speed;
        this.x -= (this.x - GameUtils.gameObjList.get(GameWin.planeindex).getX()) / 30;

        for (ShellObj shellObj : GameUtils.shellObjList) {
            if(this.getRec().intersects(shellObj.getRec())){
                // 碰撞之后出现爆炸动画
                ExplodeObj explodeObj = new ExplodeObj(x, y);
                GameUtils.explodeObjsList.add(explodeObj);
                GameUtils.removeList.add(explodeObj);

                this.x = -100;
                this.y = -100;
                GameUtils.removeList.add(shellObj);
                GameUtils.removeList.add(this);
//                GameWin.score += 3;
            }
        }

    }
}
